{{if false}}<script>{{/if}}
function delete_selected_record(un){
    try{
        var cells = myGrid.jqxGrid('getselectedcells');
        
        var _ids=new Array();
        if(cells.length>0){
            for(var i=0;i<cells.length;i++){
                if(cells[i].rowindex!=undefined){
                    var _dataRow=myGrid.jqxGrid('getrowdata', cells[i].rowindex);
                    var _id=_dataRow._id==undefined?(_dataRow.ID==undefined?_dataRow.ProductID:_dataRow.ID):_dataRow._id;
                    if(_id!=undefined && !_ids.in_array(_id)){
                        _ids.push(_id);
                    }
                }
            }
            if(_ids.length>0){
                var url,data,tit;
                if(un==true){
                    url="{{base_url()}}backend/fe548e5a964095e7c80cd8d3721be2ef/restore/{{$token}}/{{$controller}}";
                    tit="Do you want restore selected record?<br/>";
                }else{
                    url="{{base_url()}}backend/fe548e5a964095e7c80cd8d3721be2ef/delete/{{$token}}/{{$controller}}";
                    tit="Do you want delete selected record?<br/>";
                }
                ShowConfirmDialogMessage(tit+_ids.length+" record","Confirm ?",function(){
                    CloseConfirmDialogMessage();
                    console.log("Delete:\nIDs:"+_ids+" ↵ Call");
                    data={
                        _id      :   _ids
                    }
                    isrunning=true;
                    myAjax(url,data,function(o){
                        isrunning=false;
                        if(o.result>=0){
                            uiMessage(o.message);
                            myGrid.jqxGrid('updatebounddata');
                        }else{
                            ShowErrorDialogMessage(o.message);
                        }
                    });
                });
            }else{
                uiMessage("No row selected. Please select one or more rows.");
            }
        }else{
            uiMessage("No row selected. Please select one or more rows.");
        }
    }catch(e){
        console.log("JSON Error:"+e.message+"\n↵ Error");
        uiMessage(e.message);
        //ShowErrorDialogMessage("Sorry. Your request could not be completed.<br/> Please check your input data.");
    }
}
function change_status_selected_record(_status){
    try{
        _status=_status=='true'?'Public':'Private';
        var cells = myGrid.jqxGrid('getselectedcells');
        var _ids=new Array();
        if(cells.length>0){
            for(var i=0;i<cells.length;i++){
                if(cells[i].rowindex!=undefined){
                    var _dataRow=myGrid.jqxGrid('getrowdata', cells[i].rowindex);
                    var _id=_dataRow._id==undefined?(_dataRow.ID==undefined?_dataRow.ProductID:_dataRow.ID):_dataRow._id;
                    if(_id!=undefined && !_ids.in_array(_id)){
                        _ids.push(_id);
                    }
                }
            }
            if(_ids.length>0){
                ShowConfirmDialogMessage("Do you want change status of selected record?<br/>"+_ids.length+" record","Delete?",function(){
                    CloseConfirmDialogMessage();
                    console.log("Status:\nIDs:"+_ids+" ↵ Call");
                    var url,data;
                    url="{{base_url()}}backend/fe548e5a964095e7c80cd8d3721be2ef/change_status/{{$token}}/{{$controller}}";
                    data={
                        _id     :   _ids,
                        _status :   _status
                    }
                    isrunning=true;
                    myAjax(url,data,function(o){
                        isrunning=false;
                        if(o.result>=0){
                            uiMessage(o.message);
                            myGrid.jqxGrid('updatebounddata');
                        }else{
                            ShowErrorDialogMessage(o.message);
                        }
                    });
                });
            }else{
                uiMessage("No row selected. Please select one or more rows.");
            }
        }else{
            uiMessage("No row selected. Please select one or more rows.");
        }
    }catch(e){
        console.log("JSON Error:"+e.message+"\n↵ Error");
        uiMessage(e.message);
        //ShowErrorDialogMessage("Sorry. Your request could not be completed.<br/> Please check your input data.");
    }
}
function updateCol(_col,_id,_value){
    try{
        var url,data;
        url="{{base_url()}}backend/fe548e5a964095e7c80cd8d3721be2ef/column_update/{{$token}}/{{$controller}}/"+_col;
        data={
            _id      :   _id,
            _value   :   _value
        }
        isrunning=true;
        myAjax(url,data,function(o){
            isrunning=false;
            if(o.result>=0){
                uiMessage(o.message);
            }else{
                uiMessage(o.message);
                //ShowNoticeDialogMessage(result.msg);
            }
        });
    }catch(e){
        console.log("JSON Error:"+e.message+"\n↵ Error");
        uiMessage(e.message);
        //ShowErrorDialogMessage("Sorry. Your request could not be completed.<br/> Please check your input data.");
    }
}